local zongshi = fk.CreateSkill {
  name = "rmt__zongshi"
}

Fk:loadTranslationTable{
  ["rmt__zongshi"] = "纵势",
  [":rmt__zongshi"] = "出牌阶段，你可以将任意张牌当【万箭齐发】使用，但须满足：1.包含本回合首次转化的花色；2.转化牌数量为本回合首次。",

  ["@rmt__zongshi1-turn"] = "纵势",
  ["@[suits]rmt__zongshi2-turn"] = "纵势",
  ["#rmt__zongshi"] = "纵势：将任意张牌当【万箭齐发】使用，花色须含本回合未转化过的花色，数量须与本回合转化过的数量均不同。",

  ["$rmt__zongshi1"] = "四世三公之家，当为天下之望。",
  ["$rmt__zongshi2"] = "大势在我，可怀问鼎之心。"
}

zongshi:addEffect("viewas", {
  anim_type = "offensive",
  prompt = "#rmt__zongshi",
  pattern = "archery_attack",
  handly_pile = true,
  card_filter = function(self, player, to_select, selected)
    return true
  end,
  view_as = function(self, player, cards)
    if #cards <= 0 or table.contains(player:getTableMark("@rmt__zongshi1-turn"), #cards) 
    or not table.find(cards, function(id) return not table.contains(player:getTableMark("@[suits]rmt__zongshi2-turn"), Fk:getCardById(id).suit) end) then return end
    local c = Fk:cloneCard("archery_attack")
    c.skillName = self.name
    c:addSubcards(cards)
    return c
  end,
  before_use = function (self, player, use)
    player.room:addTableMark(player, "@rmt__zongshi1-turn", #use.card.subcards)
    for _, id in ipairs (use.card.subcards) do
      if not table.contains(player:getTableMark("@[suits]rmt__zongshi2-turn"), Fk:getCardById(id).suit) then
        player.room:addTableMark(player, "@[suits]rmt__zongshi2-turn", Fk:getCardById(id).suit)
      end
    end
  end,
  enabled_at_play = function(self, player)
    return not player:isNude()
  end,
  enabled_at_response = Util.FalseFunc,
})

return zongshi
